package com.jiangxjsy.core.security.kit;

import lombok.Getter;

import java.io.Serializable;
import java.util.Objects;

/**
 * wukong-crm-master
 * 蒋胜宇
 * 2025/6/5 11:36
 */

@Getter
public final class EncodedCredential implements Serializable {
    private static final long serialVersionUID = 1L;
    private static final Algorithm DEFAULT_ALGORITHM = Algorithm.UNKNOWN;

    private final String passwordHash;
    private final String salt;
    private final Algorithm algorithm;

    public EncodedCredential(String passwordHash, String salt) {
        this(passwordHash, salt, DEFAULT_ALGORITHM);
    }

    public EncodedCredential(String passwordHash, String salt, Algorithm algorithm) {
        this.passwordHash = Objects.requireNonNull(passwordHash, "password hash cannot be null");
        this.salt = salt != null ? salt : "";
        this.algorithm = algorithm != null ? algorithm : DEFAULT_ALGORITHM;
    }
}
